<template>
  <li >
    <span class="p-tit">{{cate.goClaName}}</span>
    <span class="p-num" v-if="cateNum>0">{{cateNum}}</span>
  </li>
</template>

<script lang="babel">
  import { mapGetters } from 'vuex'
  export default {
    props: ['cate'],
    computed: {
      ...mapGetters({
        getCart: 'frontend/cart/getCart'
      }),
      cateNum () {
        let _this = this;
        let shopId = this.$route.params.shopId;
        let cateNum = 0;
        if(this.getCart[shopId]) {
          let goodsFilter = this.getCart[shopId].goods.filter((item) => {
            return item.goClaId == this.cate.goClaId
          })
          goodsFilter.forEach((item) => {
            cateNum += item.goNum
          })
        }
        return cateNum
      }
    }
  }
</script>